function getLight(pars){
	if(pars=="open"){
		close_light(this);
	}else{
		close_light(this);
	}
}
function thisMovie(movieName){
	if(navigator.appName.indexOf("Microsoft")!=-1){
		return window[movieName];
	}else{
		return document[movieName];
	}
}
function close_light(d){
	if($("#close_light_bg").css("display")=="none"){
		d.id="light_a";
		document.getElementById("CuPlayer").style.zIndex="1002";
		document.getElementById("CuPlayer").style.position="relative";
		document.getElementById("close_light_bg").style.position="fixed";
		document.getElementById("close_light_bg").style.top="0";
		document.getElementById("close_light_bg").style.left="0";
		document.getElementById("close_light_bg").style.background="#000";
		document.getElementById("close_light_bg").style.zIndex="1001";
		var b=document.documentElement.scrollWidth;
		var c=$(document).height();
		$("#close_light_bg").css({width:b,height:c});
		$("#close_light_bg").show();
		var a=document.createElement("div");
		a.id="light_div";
		a.innerHTML="开灯";
		a.style.width="28px";
		a.style.height="22px";
		a.style.lineHeight="22px";
		a.style.paddingLeft="15px";
		a.style.background="url(filmbase100401.jpg) no-repeat scroll 0 -176px";
		a.style.color="#656565";
		a.style.position="absolute";
		a.style.left=getLeft(d)+"px";
		a.style.top=getTop(d)+"px";
		a.style.zIndex="1000";
		a.style.cursor="pointer";
		a.onclick=function(){
			_detachEvent(window,"resize",setposition);
			document.body.removeChild(a);
			close_light(d)
		};
		a.onmouseover=function(){
			light_bgch(0,a)
		};
		a.onmouseout=function(){
			light_bgch(1,a)
		};
		document.body.appendChild(a);
		_attachEvent(window,"resize",setposition)
	}else{
		document.getElementById("CuPlayer").style.zIndex="0";
		$("#close_light_bg").hide()
	}
}
function close_light_play(d){
	if($("#close_light_bg").css("display")=="none"){
		d.id="light_a";
		document.getElementById("CuPlayer").style.zIndex="1002";
		document.getElementById("CuPlayer").style.position="relative";
		document.getElementById("close_light_bg").style.position="fixed";
		document.getElementById("close_light_bg").style.top="0";
		document.getElementById("close_light_bg").style.background="#000";
		document.getElementById("close_light_bg").style.left="0";
		document.getElementById("close_light_bg").style.zIndex="1001";
		var b=document.documentElement.scrollWidth;
		var c=$(document).height();
		$("#close_light_bg").css({width:b,height:c});
		$("#close_light_bg").show();
		var a=document.createElement("div");
		a.id="light_div";
		a.innerHTML="开灯";
		a.style.width="28px";
		a.style.height="22px";
		a.style.lineHeight="22px";
		a.style.paddingLeft="15px";
		a.style.background="url(/playbase100402.jpg) no-repeat scroll -1px -240px";
		a.style.color="#656565";
		a.style.position="absolute";
		a.style.left=getLeft(d)+"px";
		a.style.top=getTop(d)+"px";
		a.style.zIndex="1000";
		a.style.cursor="pointer";
		a.onclick=function(){
			_detachEvent(window,"resize",setposition);
			document.body.removeChild(a);
			close_light_play(d)
		};
		a.onmouseover=function(){
			light_bgch_db(0,a)
		};
		a.onmouseout=function(){
			light_bgch_db(1,a)
		};
		document.body.appendChild(a);
		_attachEvent(window,"resize",setposition)
	}else{
		document.getElementById("CuPlayer").style.zIndex="10";
		$("#close_light_bg").hide()
	}
}
function _detachEvent(obj,evt,func){
	if(obj.removeEventListener){
		obj.removeEventListener(evt,func,true)
	}else{
		if(obj.detachEvent){
			obj.detachEvent("on"+evt,func)
		}else{
			eval(obj+".on"+evt+"=old"+func+";")
		}
	}
}
function _attachEvent(obj, evt, func) {
    if (obj.addEventListener) {
        obj.addEventListener(evt, func, true)
    } else {
        if (obj.attachEvent) {
            obj.attachEvent("on" + evt, func)
        } else {
            eval("var old" + func + "=" + obj + ".on" + evt + ";");
            eval(obj + ".on" + evt + "=" + func + ";")
        }
    }
}
function setposition() {
    $("#light_div").css("left", getLeft(document.getElementById("light_a")) + "px");
    var a = document.documentElement.scrollWidth;
    var b = $(document).height();
    $("#close_light_bg").css({
        width: a,
        height: b
    })
}
function light_bgch(b, a) {
    if (b == 0) {
        if (a.currentStyle) {
            $(a).css({
                backgroundPositionX: "0",
                backgroundPositionY: "-176px"
            })
        } else {
            a.style.backgroundPosition = "0 -176px"
        }
        $(a).css({
            color: "#ff6523"
        });
        $(a).css({
            textDecoration: "underline "
        })
    } else {
        if (a.currentStyle) {
            $(a).css({
                backgroundPositionX: "-57px",
                backgroundPositionY: "-176px"
            })
        } else {
            a.style.backgroundPosition = "-57px -176px"
        }
        $(a).css({
            color: "#656565"
        });
        $(a).css({
            textDecoration: "none "
        })
    }
}
function light_bgch_db(b, a) {
    if (b == 0) {
        if (a.currentStyle) {
            $(a).css({
                backgroundPositionX: "-1px",
                backgroundPositionY: "-240px"
            })
        } else {
            a.style.backgroundPosition = "-1px -240px"
        }
        $(a).css({
            color: "#54990b"
        });
        $(a).css({
            textDecoration: "underline "
        })
    } else {
        if (a.currentStyle) {
            $(a).css({
                backgroundPositionX: "-58px",
                backgroundPositionY: "-240px"
            })
        } else {
            a.style.backgroundPosition = "-58px -240px"
        }
        $(a).css({
            color: "#656565"
        });
        $(a).css({
            textDecoration: "none"
        })
    }
}
var vID        = ""; 
var vWidth     = "";
var vHeight    = "";
var vFile      = "/xpt/root/default/other/CuSunV2set.xml";
var vPlayer    = "/xpt/root/default/other/player.swf?v=2.5";
var vPic       = "";
var vServer    = "";
var vMp4url    = "";
var vIosurl    = "";

function init() {
	var $imgList = jQuery("img[qs_type='video']");
	var imgList = [];
	for( var i = 0; i < $imgList.length; i++ ){
		imgList[i] = $imgList[i];
	}
	
	for(var i = 0; i < imgList.length; i++) {
		var domEle = imgList[i];
		var $el = jQuery(domEle);
		var maid = $el.attr("qs_maid");
		var type = $el.attr("qs_media_type");
		var height = $el.height();
		var width = $el.width();
		if($el.prev().length > 0) {
			height = $el.prev().height();
			width = $el.prev().width();
		}
		vWidth     = width;
		vHeight    = height;
		//视频文件及略缩图--------------------------
		if(type == "2") {
			if(maid.indexOf("http://") < 0) {
				var index = 0;
				for(var j = 0; j < 4; j ++) {
					index = maid.indexOf("/", index + 1);
				}
			    maid = maid.replace("183.136.159.155", "zb.nbtv.cn:443");
				vServer = maid.substr(0, index);
				vMp4url    = "mp4:" + maid.substr(index);
				maid = maid.replace("rtmp", "http");
				maid = maid.replace("cuhd", "cug");

				vIosurl    = maid;
				document.write('<script class="CuPlayerVideo" data-mce-role="CuPlayerVideo" type="text/javascript" src="/xpt/root/default/js/AsComV5.js"><\/script>'); 
			} else {
				vServer    = "";

				vMp4url = maid
				vIosurl    = maid;
				document.write('<script class="CuPlayerVideo" data-mce-role="CuPlayerVideo" type="text/javascript" src="/xpt/root/default/js/AsComV3.js"><\/script>'); 
			}
		} else if(type == "3") {
			if(maid.indexOf("http://") < 0) {
				var index = 0;
				for(var j = 0; j < 100; j ++) {
					var index2 = maid.indexOf("/", index + 1);
					if(index2 < 0) {
						break;
					}
					index = index2
				}
				var so = new SWFObject("/xpt/root/default/other/mp3MusicPlayer.swf","ply","600","32","9","#000000");
				so.addParam("allowfullscreen","true");
				so.addParam("allowscriptaccess","always");
				so.addParam("wmode","opaque");
				so.addParam("quality","high");
				so.addParam("salign","lt");
				so.addVariable("autostart","true");
				so.addVariable("server", maid.substr(0, index));
				so.addVariable("file", maid.substr(index));
				so.write("CuPlayer");
			} else {
				var so = new SWFObject("/xpt/root/default/other/mp3MusicPlayer.swf","ply","600","32","9","#000000");
				so.addParam("allowfullscreen","true");
				so.addParam("allowscriptaccess","always");
				so.addParam("wmode","opaque");
				so.addParam("quality","high");
				so.addParam("salign","lt");
				so.addVariable("autostart","true");
				so.addVariable("server", "");
				so.addVariable("file", maid);
				so.write("CuPlayer");
			}
		}
		//$(".CuPlayerVideo").attr("src", "/xpt/root/default/js/AsComV5.js");
		//$("#vvvvid").html('<script class="CuPlayerVideo" data-mce-role="CuPlayerVideo" type="text/javascript" src="/xpt/root/default/js/AsComV5.js"><\/script>');
	}
}
function create_video(divid, maid) {
	//var $domEle = jQuery("#" + divid);
	//var html = '<div class="video" id="CuPlayer"></div>';
	//$domEle.prop('outerHTML', html);
	vWidth     = 640;
	vHeight    = 480;
	maid = maid.replace("183.136.159.155", "zb.nbtv.cn");
	maid = maid.replace("rtmp://zb.nbtv.cn", "http://mobile.nbtv.cn");
	maid = maid.replace("http://zb.nbtv.cn", "http://mobile.nbtv.cn");
	maid = maid.replace("rtmp", "http");
	//视频文件及略缩图--------------------------
	if (/android/i.test(navigator.userAgent)){
	    
	}
	
	if (/ipad|iphone|mac/i.test(navigator.userAgent)){
	    
	}

	if(maid.indexOf("http://") < 0) {
		maid = maid.replace("zb.nbtv.cn", "zb.nbtv.cn:443");
		var index = 0;
		for(var j = 0; j < 4; j ++) {
			index = maid.indexOf("/", index + 1);
		}
		vServer = maid.substr(0, index);
		//maid = maid.replace("cuhd", "cug");
		vMp4url    = "mp4:" + maid.substr(index);
		maid = maid.replace("rtmp", "http");
		maid = maid.replace("zb.nbtv.cn:443", "mobile.nbtv.cn");
		maid = maid.replace("cuhd", "cug");
		vIosurl    = maid;

	} else {
		vServer    = "";
		vMp4url = maid
		maid = maid.replace("cuhd", "cug");
		vIosurl    = maid;
	}
}
function create_mp3(divid, maid) {
	maid = maid.replace("http://zb.nbtv.cn", "http://mobile.nbtv.cn");
	maid = maid.replace("http://vms.nbtv.cn", "http://mobile.nbtv.cn");
	var $domEle = jQuery("#" + divid);
	var html = '<script>audiojs.events.ready(function() {var as = audiojs.createAll();});</script><audio src=' + maid + '></audio>';
	//$domEle.prop('outerHTML', html);
	$("#CuPlayer").html(html);
		var so = new SWFObject("/xpt/root/default/other/mp3MusicPlayer.swf","ply","500","32","9","#000000");
		so.addParam("allowfullscreen","true");
		so.addParam("allowscriptaccess","always");
		so.addParam("wmode","opaque");
		so.addParam("quality","high");
		so.addParam("salign","lt");
		so.addVariable("autostart","true");
		so.addVariable("server", "");
		so.addVariable("file", maid);
		so.write("CuPlayer");

}
function create_video_live(divid, server, mp4url, iosurl, width, height) {
	vWidth     = width;
	vHeight    = height;
	server = server.replace("zb.nbtv.cn", "zb.nbtv.cn:443");
	//PC,安卓
	vServer    = server;
	vMp4url    = mp4url;
	//iOS
	vIosurl    = iosurl;
}


          